package top.sigetech.springcloud.alibaba.controller;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import top.sigetech.springcloud.entity.Payment;
import top.sigetech.springcloud.vo.CommonResult;

import java.util.HashMap;

@RestController
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hashMap = new HashMap<>();

    static {
        hashMap.put(1L,new Payment(1L,"das98723aadg978wqa4sad54w"));
        hashMap.put(2L,new Payment(2L,"asd546251232das4564564658"));
        hashMap.put(3L,new Payment(3L,"gaga687123as14d8253asf78g"));
    }

    @GetMapping("/paymentSQL/{id}")
    public CommonResult<Payment> paymentSQL(@PathVariable("id")Long id){
        Payment payment = hashMap.get(id);
        return new CommonResult<>(200, "from mysql,serverPort：" + serverPort, payment);
    }
}
